package com.example.sls.service.impl.admin.defaultTable;

import com.example.sls.mapper.admin.defaultTable.EmpDtMapper;
import com.example.sls.pojo.admin.defaultTable.EmpDt;
import com.example.sls.service.admin.defaultTable.EmpDtService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EmpDtServiceImpl implements EmpDtService {

    @Autowired
    EmpDtMapper empDtMapper;

    @Override
    public Boolean addData(EmpDt emp) {
        boolean flag = false;
        if(empDtMapper.addData(emp) > 0){
            flag = true;
        }
        return flag;
    }

    @Override
    public Boolean updateData(Map<String, Object> emp) {
        boolean flag = false;
        if(empDtMapper.updateData(emp) > 0){
            flag = true;
        }
        return flag;
    }

    @Override
    public Boolean deleteData(Integer id) {
        boolean flag = false;
        if(empDtMapper.deleteData(id) > 0){
            flag = true;
        }
        return flag;
    }

    @Override
    public List<EmpDt> queryAllData() {
        return empDtMapper.queryAllData();
    }

    @Override
    public Integer getCount() {
        return empDtMapper.getCount();
    }

    @Override
    public Integer getMaxId() {
        return empDtMapper.getMaxId();
    }

    @Override
    public PageInfo<EmpDt> getAllDataByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<EmpDt> emp = empDtMapper.queryAllData();
        PageInfo<EmpDt> accountPageInfo = new PageInfo<>(emp);

        return accountPageInfo;
    }
}
